package com.rt.schedulenew.web;

import com.github.pagehelper.Page;
import com.rt.schedulebase.dto.ChartsDto;
import com.rt.schedulebase.entity.commonentity.PageResultUtil;
import com.rt.schedulenew.utils.global.ErrorCode;
import com.github.pagehelper.PageHelper;
import java.util.List;
import com.rt.schedulebase.dto.BreakPromiseCountDto;
import org.springframework.web.bind.annotation.PostMapping;
import java.util.Map;
import com.rt.schedulenew.utils.global.JsonResultUtil;
import com.rt.schedulenew.utils.global.JsonResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.beans.factory.annotation.Autowired;
import com.rt.schedulenew.api.IChartsService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/***
 * 统计相关
 */
@RestController
@RequestMapping({"/charts"})
public class ChartsController {
    @Autowired
    private IChartsService chartsService;

    /**
     * 预约量统计-日-申请院区
     *
     * @param dto
     * @return
     */
    @PostMapping({"/reqHospitalCount"})
    public JsonResult getReqHospitalCount(@RequestBody ChartsDto dto) {
        Map<String, Object> map = chartsService.getReqHospitalCount(dto);
        return JsonResultUtil.success("成功", map);
    }

    @PostMapping({"/terminalTypeCount"})
    public JsonResult getTerminalTypeCount(@RequestBody ChartsDto dto) {
        Map<String, Object> map = chartsService.getTerminalTypeCount(dto);
        return JsonResultUtil.success("成功", map);
    }

    @PostMapping({"/getPerformDeptTerminalCount"})
    public JsonResult getPerformDeptTerminalCount(@RequestBody ChartsDto dto) {
        Map<String, Object> map = chartsService.getPerformDeptTerminalCount(dto);
        return JsonResultUtil.success("成功", map);
    }

    @PostMapping({"/scheduleTerminalCount"})
    public JsonResult getScheduleTerminalCount(@RequestBody ChartsDto dto) {
        Map<String, Object> map = chartsService.getScheduleTerminalCount(dto);
        return JsonResultUtil.success("成功", (Object) map);
    }

    @PostMapping({"/reqDeptCount"})
    public JsonResult getReqDeptCount(@RequestBody ChartsDto dto) {
        Map<String, Object> map = chartsService.getReqDeptCount(dto);
        return JsonResultUtil.success("成功", map);
    }

    @PostMapping({"/performDeptCount"})
    public JsonResult getPerformDeptCount(@RequestBody ChartsDto dto) {
        Map<String, Object> map = chartsService.getPerformDeptCount(dto);
        return JsonResultUtil.success("成功", map);
    }

    @PostMapping({"/examQueueCount"})
    public JsonResult getExamQueueCount(@RequestBody ChartsDto dto) {
        Map<String, Object> map = chartsService.getExamQueueCount(dto);
        return JsonResultUtil.success("成功", map);
    }

    @PostMapping({"/getUserScheduleCount"})
    public JsonResult getUserScheduleCount(@RequestBody ChartsDto dto) {
        Map<String, Object> map = chartsService.getUserScheduleCount(dto);
        return JsonResultUtil.success("成功", map);
    }

    /**
     * 爽约统计报表
     * @param dto
     * @return
     */
    @PostMapping({"/reqDeptBreakPromiseCount"})
    public JsonResult getReqDeptBreakPromiseCount(@RequestBody BreakPromiseCountDto dto) {
        List<Map<String, Object>> list = chartsService.getReqDeptBreakPromiseCount(dto);
        return JsonResultUtil.success("成功", list);
    }

    @PostMapping({"/scheduleWordloadCount"})
    public JsonResult scheduleWordLoadCount(@RequestBody ChartsDto dto) {
        List<ChartsDto> list = (List<ChartsDto>) chartsService.scheduleWordloadCount(dto);
        return JsonResultUtil.success("成功", (Object) list);
    }

    /**
     * 预约占号率
     * @param dto
     * @return
     */
    @PostMapping({"/getScheduleOrgansCount"})
    public JsonResult getScheduleOrgansCount(@RequestBody ChartsDto dto) {
        Map<String, Object> map = chartsService.getScheduleOrgansCount(dto);
        return JsonResultUtil.success(map);
    }

    @PostMapping({"/getSignInCount"})
    public JsonResult getSignInCount(@RequestBody ChartsDto dto) {
        Map<String, Object> map = chartsService.getSignInCount(dto);
        return JsonResultUtil.success(map);
    }

    @PostMapping({"/getReqPhysicianCount"})
    public JsonResult getReqPhysicianCount(@RequestBody ChartsDto dto) {
        Map<String, Object> map = chartsService.getReqPhysicianCount(dto);
        return JsonResultUtil.success("成功", map);
    }

    @PostMapping({"/getScheduleCount"})
    public JsonResult getScheduleCount(@RequestBody ChartsDto dto) {
        Page<Map<String, Object>> page = PageHelper.startPage(dto.getPageNo(), dto.getPageSize());
        List<Map<String, Object>> list = chartsService.getScheduleCount(dto);
        return PageResultUtil.success(ErrorCode.SUCCESS.getValue(), list, page);
    }
}
